package com.deuwise.system.controller;/*
package com.deuwise.system.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.deuwise.common.utils.FileHelperUtils;
import com.deuwise.common.utils.LogUtils;
import com.deuwise.common.utils.R;
import com.deuwise.common.utils.RSAUtils;
import com.deuwise.common.utils.authorize.SerialNumberUtil;
import com.deuwise.system.entity.DictDo;
import com.deuwise.system.entity.KeyPairDo;
import com.deuwise.system.service.DictDoService;
import com.deuwise.system.service.KeyPairDoService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.ibatis.cache.CacheKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.wf.captcha.ArithmeticCaptcha;
import com.wf.captcha.ChineseCaptcha;
import com.wf.captcha.GifCaptcha;
import com.wf.captcha.SpecCaptcha;
import com.wf.captcha.base.Captcha;
*/
/**
 * Copyright
 *
 * @Author:chenwenchao
 * @Date:2018/11/2 0002
 * Description:
 *//*

@Controller()
@RequestMapping("/test")
public class TestController {


    @ApiOperation("测试单元日志")
    @GetMapping("/测试单元测试")
    public void test(){

        LogUtils.logError("1231");
        LogUtils.logDebug("213213");
        LogUtils.logInfo("213131231");

    }
    @ApiOperation("获取日志文件夹")
    @GetMapping("testDir")
    public  void testDir(HttpServletRequest request){
        //获取跟目录
        File path = null;
        try {
            path = new File(ResourceUtils.getURL("").getPath());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        if(!path.exists()) {
            path = new File("");
        }
       String logPath= FileHelperUtils.getLogSavePath();
        System.out.println("path:"+path.getAbsolutePath());
        String pathStr=path.getAbsolutePath()+"/"+logPath;
        File dir = new File( pathStr);
        if ( !dir.exists() ) {
            System.out.println("不存在");
        }

        if ( !dir.isDirectory() ) {
            System.out.println("不存在目录");
        }

        Collection<File> list = FileUtils.listFiles(dir, FileFilterUtils.suffixFileFilter("log"), FileFilterUtils.suffixFileFilter("") );
        String aa="";


        System.out.println("目录文件有数量："+list.size());
    }
    */
/**
     * 获取CPU序列号 linux
     *
     * @return
     *//*

    public  String getCPUID_linux() throws InterruptedException {
        System.out.println("进行管道控制");
        String result = "";
        String CPU_ID_CMD = "dmidecode";
        BufferedReader bufferedReader = null;
        Process p = null;
        try {
            p = Runtime.getRuntime().exec(new String[] { "sh", "-c", CPU_ID_CMD });// 管道
            bufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line = null;
            int index = -1;
            while ((line = bufferedReader.readLine()) != null) {
                // 寻找标示字符串[hwaddr]
                index = line.toLowerCase().indexOf("uuid");
                if (index >= 0) {// 找到了
                    // 取出mac地址并去除2边空格
                    result = line.substring(index + "uuid".length() + 1).trim();
                    break;
                }
            }

        } catch (IOException e) {
            System.out.println("获取cpu信息错误");
        }
        return result.trim();
    }

    @GetMapping("testFile")
    @ResponseBody
    public R testFIle(){
        SerialNumberUtil.getDiskNo();
        return R.ok("");
    }


    @GetMapping("ReadFile/{id}")
    @ResponseBody
    public R ReadFile(@PathVariable("id")String id){
        try {
            System.out.println("进来了");
            return R.ok(getCPUID_linux());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return  R.ok();
    }
    @GetMapping("/testIp")
    @ApiOperation("获取ip信息")
    @ResponseBody
    public R testIp(HttpServletRequest request){
        String ip = null;

      String nStrings=request.getHeaderNames().toString();
      try {
          ip = request.getHeader("X-Forwarded-For");
          String dataStr="X-Forwarded-For"+ip+"Proxy-Client-IP:" + request.getHeader("Proxy-Client-IP") + "," + "x-forwarded-for" +
                  request.getHeader("x-forwarded-for") + "WL-Proxy-Client-IP" + request.getHeader("WL-Proxy-Client-IP") +
                  "HTTP_CLIENT_IP" + request.getHeader("HTTP_CLIENT_IP");
          return R.ok(dataStr);
      }catch (Exception ex){
          ex.printStackTrace();
      }
      return  R.error();

    }


    @ApiOperation(value = "验证码", notes = "验证码")
    @GetMapping(value = "/captcha", produces = "image/png")
    public void captcha(@RequestParam(value = "key") String key, HttpServletResponse response) throws IOException {
        create(key, response);
    }

    public void create(String key, HttpServletResponse response) throws IOException {

        setHeader(response, "arithmetic");

        Captcha captcha = createCaptcha("arithmetic");
        System.out.println(captcha.text());
       // cache.set(CacheKey.CAPTCHA, key, org.apache.commons.lang3.StringUtils.lowerCase(captcha.text()));
        captcha.out(response.getOutputStream());
    }

    private Captcha createCaptcha(String type) {
        Captcha captcha = null;
        if (org.apache.commons.lang3.StringUtils.equalsIgnoreCase(type, "gif")) {
            captcha = new GifCaptcha(115, 42, 4);
        } else if (org.apache.commons.lang3.StringUtils.equalsIgnoreCase(type, "png")) {
            captcha = new SpecCaptcha(115, 42, 4);
        } else if (org.apache.commons.lang3.StringUtils.equalsIgnoreCase(type, "arithmetic")) {
            captcha = new ArithmeticCaptcha(115, 42);
        } else if (org.apache.commons.lang3.StringUtils.equalsIgnoreCase(type, "chinese")) {
            captcha = new ChineseCaptcha(115, 42);
        }
        captcha.setCharType(2);
        return captcha;
    }

    private void setHeader(HttpServletResponse response, String type) {
        if (org.apache.commons.lang3.StringUtils.equalsIgnoreCase(type, "gif")) {
            response.setContentType(MediaType.IMAGE_GIF_VALUE);
        } else {
            response.setContentType(MediaType.IMAGE_PNG_VALUE);
        }
        response.setHeader(HttpHeaders.PRAGMA, "No-cache");
        response.setHeader(HttpHeaders.CACHE_CONTROL, "No-cache");
        response.setDateHeader(HttpHeaders.EXPIRES, 0L);
    }




}
*/
